/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Engine2D.gui;

import Engine2D.graphics.font.GLFont;
import Engine2D.engine.Engine;
import Engine2D.graphics.GLColour;
import Engine2D.graphics.GLColour;
import java.util.ArrayList;
import org.lwjgl.opengl.Display;


/**
 *
 * @author Garys
 */
public class GLTextConsole {

    private ArrayList<Line> lines = null;
    private int maxLines;
    private GLFont font = null;
    private GLColour backGroundColour = null;
    private GLColour textColour = null;

    /**
     * 
     * @param font
     * @param maxLines
     * @param backGroundColour
     * @param textColour
     */
    public GLTextConsole(GLFont font, int maxLines, GLColour backGroundColour, GLColour textColour) {

        this.font = font;
        this.maxLines = maxLines;
        lines = new ArrayList<Line>();
        this.backGroundColour = backGroundColour;
        this.textColour = textColour;
    }

    
    /**
     * 
     * @param number
     * @param x
     * @param y
     * @param zoom
     * @param withBox
     */
    public void draw(int number, int x, int y, float zoom, boolean withBox) {

        if (withBox) {
            Engine.getInstance().drawQuad(0, 0, Display.getWidth(), (y + ((number * ((int) zoom * 12)) + font.getCharSize())), backGroundColour);
        }

        for (int i = lines.size() - number; i < lines.size(); i++) {

            if(i> 0){
                Line line = lines.get(i);
                font.print(line.string, x, y, zoom, line.color);
                y += ((int) zoom * 12);
            }
           
        }

    }

    /**
     * 
     * @param string
     * @param color
     */
    public void addLine(String string, GLColour color) {

        Line line = new Line(string, color);
        lines.add(line);

    }

    /**
     * 
     * @param index
     */
    public void removeLineAt(int index) {
        lines.remove(index);
    }

    /**
     * 
     * @return
     */
    public int getSize() {
        return lines.size();
    }
}
class Line {

    public String string;
    public GLColour color;

    public Line(String mText, GLColour mColour) {
        string = mText;
        color = mColour;
    }
}
